<template>
  <FGDialog ref="FGDialog" title="编辑数据" width="900px" top="8vh" @confirm="confirm">
    <CodeEditor
      v-model="code"
      :mode="mode"
      :name="name"
      :params="params"
      :placeholder="placeholder"
    />
  </FGDialog>
</template>

<script>
import CodeEditor from "./CodeEditor";
export default {
  name: "CodeDialog",
  components: {
    CodeEditor,
  },
  props: {
    // 表示当前编辑器类型
    mode: {
      type: String,
      // text/javascript js编辑器
      // application/json json编辑器
      // text/html html编辑器
      // text/css css编辑器
      default: "application/json",
    },
    // 方法名
    name: {
      type: String,
      default: "",
    },
    // 参数
    params: {
      type: String,
      default: "",
    },
    placeholder: {
      type: String,
      default: "",
    },
  },
  data() {
    return {
      code: "",
    };
  },
  methods: {
    open(data) {
      if (data) this.code = data;
      this.$refs.FGDialog.open();
    },
    confirm() {
      this.$emit("input", this.code);
      this.$emit("confirm", this.code);
      this.$refs.FGDialog.close();
    },
    handleCodeChange(code) {
      console.log(code);
    },
  },
};
</script>

<style lang="scss" >
</style>